home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / BLOBS.ZIP / BLOBS.ASM next >
Assembly Source File  |  1996-04-04  |  4KB  |  154 lines

  1. ;*****************************************************************************
  2. ;*                                                                           *
  3. ;* Wobbler 1.0                                                               *
  4. ;* This code takes the function : z = (x+y), and instead of just doing it    *
  5. ;* the old boring way, it takes X and offsets it by htable[y] and offsets    *
  6. ;* Y by vtable[x]. htable and vtable are two arrays of sinewaves. Then, it   *
  7. ;* takes the value of the old pixels, adds it to 'Z', and plots it.          *
  8. ;* This means it feeds back .... much more interesting than colour cycling   *
  9. ;* By TH/20/3/96                                                             *
  10. ;* tomh@globalnet.co.uk                                                      *
  11. ;*                                                                           *
  12. ;*****************************************************************************
  13.  
  14.     .386
  15.         .MODEL  USE16 SMALL
  16.         .STACK 500h
  17.     JUMPS
  18.     LOCAL
  19.     SMART
  20.     PUBLIC    _IMAGE_move_wobbles
  21.     PUBLIC    _WOBBLE_pattern
  22. dopixel MACRO
  23.         LOCAL   @@no_reset
  24.     mov    si, [htableptr]
  25.     mov    bx, cx
  26.     mov    ax, [si]
  27.         add     bx, ax
  28.  
  29.     mov    si, [vtableptr]
  30.     mov    dx, bp
  31.     mov    ax, [si]
  32.     add    dx, ax
  33.  
  34.         xor     ah, ah
  35.         add     bx, dx
  36.         mov     al, es:[di]
  37.         add     bx, ax
  38.         mov     es:[di], bl
  39.         inc     di
  40.     mov    ax, [vtableptr]
  41.     add    ax, 2
  42.         dec     cx
  43.     mov    [vtableptr], ax
  44. ENDM
  45. WAIT_RETRACE = 0
  46.     .DATA
  47.     INCLUDE    htable.inc
  48.     INCLUDE    vtable.inc
  49.         INCLUDE palette.inc
  50. credits         DB      'Dancing blobs', 13, 10, 'By Tom Hammersley 1996',13,10,'$'
  51. htableptr    DW    0
  52. vtableptr    DW    0
  53. plane_select    DB      11h
  54. pixel_count     DB      0
  55.  
  56.     .CODE
  57. _IMAGE_move_wobbles PROC
  58.     cld
  59.         mov     ax, @Data
  60.     mov    es, ax
  61.     mov    ax, [htable]
  62.     mov    [htable+400], ax
  63.     mov    si, OFFSET htable
  64.     mov    di, OFFSET htable
  65.     add    si, 2
  66.     mov    cx, 100
  67.     rep    movsd
  68.     mov    ax, [vtable]
  69.     mov    [vtable+640], ax
  70.     mov    si, OFFSET vtable
  71.     mov    di, OFFSET vtable
  72.     add    si, 2
  73.     mov    cx, 160
  74.     rep    movsd
  75.     ret
  76. _IMAGE_move_wobbles ENDP
  77.  
  78. _WOBBLE_pattern PROC
  79.     mov    ax, OFFSET htable
  80.         mov     bx, 0A000h
  81.     mov    [htableptr], ax
  82.         xor     di, di
  83.         mov     es, bx
  84.         mov     bp, 200
  85. @@row_loop:
  86.     mov    ax, OFFSET vtable
  87.         mov     cx, 320
  88.     mov    [vtableptr], ax
  89. @@pixel_loop:
  90.         dopixel
  91.         dopixel
  92.         dopixel
  93.         dopixel
  94.         jnz     @@pixel_loop
  95.  
  96.     mov    ax, [htableptr]
  97.     add    ax, 2
  98.     mov    [htableptr], ax
  99.  
  100.         dec    bp
  101.         jnz    @@row_loop
  102.     ret
  103. _WOBBLE_pattern    ENDP
  104.  
  105. main:
  106. .STARTUP
  107.         mov     ax, 0013h
  108.         int     10h
  109.         mov     dx, 3C8h
  110.         xor     ax, ax
  111.         out     dx, ax
  112.         lea     bx, palette
  113.         mov     cx, 768
  114.         mov     dx, 3C9h
  115. pal_loop:
  116.         mov     al, [bx]
  117.         out     dx, al
  118.         inc     bx
  119.         dec     cx
  120.         jnz     pal_loop
  121.     mov    ax, @Data
  122.     mov    ds, ax
  123. frame_loop:
  124. IF WAIT_RETRACE
  125.         mov     dx,3dah
  126. Vrt:                                    ; wait for a vertical retrace
  127.         in      al,dx                   ; b4 we bugger with the VGA regs
  128.         test    al,8
  129.         jnz     Vrt              
  130. NoVrt:
  131.         in      al,dx
  132.         test    al,8
  133.         jz      NoVrt
  134. ENDIF
  135.         call    _WOBBLE_pattern
  136.         call    _IMAGE_move_wobbles
  137.         in      al, 60h
  138.         cmp     al, 1
  139.         jne     frame_loop
  140.         mov     ax, 0003h
  141.         int     10h
  142.         mov     ax, @Data
  143.         mov     ds, ax
  144.         mov     dx, OFFSET credits
  145.         mov     ax, 0900h
  146.         int     21h
  147.         mov     ax, 4C00h
  148.         int     21h
  149.  
  150.         
  151. ;*****************************************************************************
  152. END main
  153.  
  154.